//
//  ARVoteViewController.m
//  AriseSamePro
//
//  Created by 包日守 on 15/11/2.
//  Copyright © 2015年 Arise. All rights reserved.
//

#import "ARVoteViewController.h"
#import "ARVoteCell.h"

@interface ARVoteViewController ()

@end

@implementation ARVoteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // [self.tableView registerNib:[UINib nibWithNibName:@"ARVoteCell" bundle:nil] forCellReuseIdentifier:@"ARVoteCell"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source


- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    float hight = 0;
    
    ARCate5Model *model = self.cateModels[indexPath.section];
    //CGFloat w = [UIScreen mainScreen].bounds.size.width - 25;
    CGRect centextRect = [model.txt boundingRectWithSize:CGSizeMake(328, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];
    
    hight = centextRect.size.height;
    
    if ([model.txt isEqualToString:@""]) {
        hight = 0;
    }
    if (model.mediaModel.voteModel.photo != nil) {
        hight += 320;
    }
    
    hight += model.mediaModel.voteModel.choices.count * 44;
    
    return hight + 109;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ARVoteCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ARVoteCell"];
    
    if (cell == nil) {
        
        
        [tableView registerNib:[UINib nibWithNibName:@"ARVoteCell" bundle:nil] forCellReuseIdentifier:@"ARVoteCell"];
        
        cell = [tableView dequeueReusableCellWithIdentifier:@"ARVoteCell"];
     
        
    }
    
    cell.cateModel = self.cateModels[indexPath.section];
    
    
    
    return cell;
    
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
